]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/theme-node: Consider scale factor when comparing
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Fri, 3 Apr 2020 20:44:54 +0000 (17:44 -0300)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Mon, 6 Apr 2020 14:24:30 +0000 (11:24 -0300)
The CSS engine of St is scale-aware, which means every length
and size it produces is multiplied by the current scale factor.

However, the individual nodes aren't aware of the scale factor
when they compare to each other.

Store and compare the scale factors in the nodes themselves.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1635

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1176

src/st/st-theme-node-private.h
src/st/st-theme-node.c

index 57f3bd6d8fd8c162d5bb6b364cfb8ec9dd9973ff..dedb3cc8f9c6b5329142cdd785c938052ec93e9e 100644 (file)
@@ -117,6 +117,8 @@ struct _StThemeNode {
   CoglPipeline *color_pipeline;
 
   StThemeNodePaintState cached_state;
+
+  int cached_scale_factor;
 };
 
 void _st_theme_node_ensure_background (StThemeNode *node);
index 31057b01294b5e2860a732aee9b24f500e340662..4e122f44107bab6640a9b57ee0130fce5c10eabf 100644 (file)
@@ -225,6 +225,7 @@ st_theme_node_new (StThemeContext    *context,
   node->element_classes = split_on_whitespace (element_class);
   node->pseudo_classes = split_on_whitespace (pseudo_class);
   node->inline_style = g_strdup (inline_style);
+  node->cached_scale_factor = st_theme_context_get_scale_factor (context);
 
   return node;
 }
@@ -345,6 +346,7 @@ st_theme_node_equal (StThemeNode *node_a, StThemeNode *node_b)
       node_a->context != node_b->context ||
       node_a->theme != node_b->theme ||
       node_a->element_type != node_b->element_type ||
+      node_a->cached_scale_factor != node_b->cached_scale_factor ||
       g_strcmp0 (node_a->element_id, node_b->element_id) ||
       g_strcmp0 (node_a->inline_style, node_b->inline_style))
     return FALSE;
@@ -396,6 +398,7 @@ st_theme_node_hash (StThemeNode *node)
   hash = hash * 33 + GPOINTER_TO_UINT (node->context);
   hash = hash * 33 + GPOINTER_TO_UINT (node->theme);
   hash = hash * 33 + ((guint) node->element_type);
+  hash = hash * 33 + ((guint) node->cached_scale_factor);
 
   if (node->element_id != NULL)
     hash = hash * 33 + g_str_hash (node->element_id);
@@ -3967,6 +3970,9 @@ st_theme_node_geometry_equal (StThemeNode *node,
 
   g_return_val_if_fail (ST_IS_THEME_NODE (other), FALSE);
 
+  if (node->cached_scale_factor != other->cached_scale_factor)
+    return FALSE;
+
   _st_theme_node_ensure_geometry (node);
   _st_theme_node_ensure_geometry (other);